import os
import xlrd2


def file_exists(file_path):
    if (os.path.isfile(file_path)):
        return True
    raise Exception('文件不存在')


def read_txt(file_path):
    file_exists(file_path)
    with open(file=file_path, encoding='utf-8') as f:
        res = []
        for line in f:
            result = line.strip().split(',')
            res.append(tuple(result))
        return res

"""
    1、如果想要 操纵 excel 表中的数据 我们需要下载 对应的模块 xlrd
"""
def read_excel(file_path):
    book = xlrd2.open_workbook(file_path)
    sheet = book.sheet_by_index(0)
    res = []
    for rx in range(sheet.nrows):
        res.append(tuple(sheet.row_values(rx)))

    return res


if __name__ == '__main__':
    print(read_excel("E:\\PythonWork\\seleniumStudy\\python\\unit\\param\\util\\data.xls"))
